package com.liu.springboot.study.controller;

import com.liu.springboot.study.domain.Result;
import com.liu.springboot.study.domain.Student;
import com.liu.springboot.study.enums.ResultEnum;
import com.liu.springboot.study.exception.StudyException;
import com.liu.springboot.study.properties.StudentProperties;
import com.liu.springboot.study.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * 2016-10-30 23:36
 */
@RestController
//@RequestMapping("/stuent")
public class StudentController {

    @Autowired
    private StudentProperties studentProperties;


    @RequestMapping(value = "/student/info")
    public Result getStudentInfo(){
        Student student = new Student();
        student.setAge(studentProperties.getAge());
        student.setName(studentProperties.getName());
//        if(true){
//            throw new StudyException(ResultEnum.STUDENT_ERROR);
//        }
        return ResultUtil.success(student);
    }


}
